package com.zqwm.fly.service;

import com.zqwm.fly.mongo.RecipeMongodb;
import com.zqwm.fly.types.PageModel;
import com.zqwm.fly.utils.DateUtil;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Calendar;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Created by songyifei on 2018-06-11.
 */

@Service
public class RecipeService {
    @Autowired
    private RecipeMongodb recipeMongodb;

    //分页列表
    public PageModel<Object> findPageList(Map<String, Object> payload)
    {
        Integer pageIndex = Integer.parseInt(payload.get("pageIndex").toString());
        Integer pageSize = Integer.parseInt(payload.get("pageSize").toString());

        payload.remove("pageIndex");
        payload.remove("pageSize");

        return recipeMongodb.findByPage(new PageModel<Object>(),pageIndex,pageSize,payload,"recipe");
    }

    //根据id查询菜谱信息
    public Object findById(Map<String,Object>map)
    {
        return recipeMongodb.findOneByItems(map,"recipe");
    }

}



